package cc11001100.snakeyaml;

import org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.regex.Pattern;

/**
 * @author CC11001100
 */
public class PatternMain {

    public static void main(String[] args) throws IOException {

        String filepath = "clusterfuzz-testcase-YamlFuzzer-5110034188599296";
        InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filepath);
        assert inputStream != null;
        String s = IOUtils.toString(inputStream, StandardCharsets.UTF_8);

        Pattern compile = Pattern.compile("^(?:[-+]?0b_*[0-1]+[0-1_]*|[-+]?0_*[0-7]+[0-7_]*|[-+]?(?:0|[1-9][0-9_]*)|[-+]?0x_*[0-9a-fA-F]+[0-9a-fA-F_]*|[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$");
        boolean matches = compile.matcher(s).matches();
        System.out.println(matches);

        // Output:
        // Exception in thread "main" java.lang.StackOverflowError
        //	at java.util.regex.Pattern$Ques.match(Pattern.java:4195)
        //	at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3812)
        //	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4672)
        //	at java.util.regex.Pattern$Loop.match(Pattern.java:4799)
        //	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4731)
        //	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3791)
        //	at java.util.regex.Pattern$Ques.match(Pattern.java:4195)
        //	at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3812)
        //	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4672)
        //	at java.util.regex.Pattern$Loop.match(Pattern.java:4799)
        //	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4731)
        //	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3791)
        //	at java.util.regex.Pattern$Ques.match(Pattern.java:4195)
        //	at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3812)
        //	at java.util.regex.Pattern$GroupHead.match(Pattern.java:4672)
        //	at java.util.regex.Pattern$Loop.match(Pattern.java:4799)
        //	at java.util.regex.Pattern$GroupTail.match(Pattern.java:4731)
        //	at java.util.regex.Pattern$CharProperty.match(Pattern.java:3791)
        //	at java.util.regex.Pattern$Ques.match(Pattern.java:4195)
        //	at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3812)
        // ......

    }
}
